<?php
	/**
	* Author:rui
	* Email:zer0131@vip.qq.com
	* 反馈前台控制器
	*/
	class IndexAction extends BaseAction{
		public function _initialize(){
	        parent::_initialize();
	    }

	    public function index(){
	    	$SEO = seo("", "", AppframeAction::$Cache['Config']['siteinfo'], AppframeAction::$Cache['Config']['sitekeywords']);
	    	$this->assign("SEO", $SEO);
	    	$this->display();
	    }

	    public function addFeedback(){
	    	$data['name'] = trim($this->_post('name'));
	    	$data['phone'] = trim($this->_post('phone'));
	    	$data['city'] = trim($this->_post('city'));
	    	$data['content'] = trim($this->_post('content'));
	    	if(empty($data['name'])){
	    		$this->error('称呼不能为空');
	    	}
	    	if(empty($data['phone'])){
	    		$this->error('电话不能为空');
	    	}
	    	if(empty($data['city'])){
	    		$this->error('请选择城市');
	    	}
	    	if(empty($data['content'])){
	    		$this->error('内容不能为空');
	    	}
	    	$data['contact'] = trim($this->_post('contact'));
	    	$obj = M('Feedback');
	    	$form = $obj->create($data);
	    	if(!$form){
	    		$this->error($obj->getError());
	    	}
	    	$obj->addtime = time();
	    	$result = $obj->add();
	    	if($result){
	    		$this->success('提交成功');
	    	}
	    	else{
	    		$this->error('出错了，请重新提交');
	    	}
	    }
	}
?>